<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>平台管理系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="/layuiadmin/layui/css/layui.css"
	media="all">
<link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
<style type="text/css">
	
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}
 
input[type="number"] {
    -moz-appearance: textfield;
}
</style>
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-card-body" style="padding: 15px;">
						<form class="layui-form" id="cashForm">
							<input type="hidden" id="scale" value="${cashRule.scale}">
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="red">*&nbsp;</span>可提现金额</label>
								<div class="layui-input-block">
									<input type="text" name="money" autocomplete="off"
										class="layui-input" value="${money}" readonly="readonly">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="red">*&nbsp;</span>银行卡</label>
								<div class="layui-input-block">
									<select name="bankId" class="select">
										<option value="">全部</option>
										<c:forEach items="${bankDetails}" var="b">
											<option value="${b.id}">${b.bankName}(${b.lastCode })</option>
										</c:forEach>
									</select>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="red">*&nbsp;</span>提现金额</label>
								<div class="layui-input-block">
									<input type="number" name="cashMoney" autocomplete="off"
										class="layui-input" value="" oninput="planRealMoney();">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="red">*&nbsp;</span>实际应到账</label>
								<div class="layui-input-block">
									<input type="text" name="realMoney" autocomplete="off"
										class="layui-input" value="0.00" readonly="readonly">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span class="red">*&nbsp;</span>提现规则</label>
								<div class="layui-input-block">
									<ul>
							          <li>◆ 单笔单日限额（实际到账最大值）<i>${cashRule.maxVal }</i></li>
							          <li>◆单笔最小金额（实际到账最小值）<i>${cashRule.minVal }</i></li>
							          <li>◆ 每个用户每天最多可提款<i>${cashRule.num }</i></li>
							          <li>◆ 单次提现手续费需扣除比例<i id="scale">${cashRule.scale}</i>（例如提现100元，经过扣除比例最终到账金额为${100*(1-cashRule.scale) }元）</li>
							          <li>◆单次提现按财务审核流程，24小时内确认完成审核</li>
							          <li>◆提现人及提现填写信息需真实有效，银行卡号及实名人需一致</li>
							          <li>◆如因本次提现方申请填写的提现信息有误造成金额错误，本平台不负任何法律责任</li>
							        </ul>
								</div>
							</div>
							<div class="layui-form-item">
				                <div class="layui-input-block">
				                  <button type="button" class="layui-btn cashThis" data-type="cashThis">申请提现</button>
				                </div>
				            </div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>

	<script src="/layuiadmin/layui/layui.js"></script>
	<script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="/js/jquery.form.js"></script>
	<script type="text/javascript" src="/js/common.js"></script>
	<script type="text/javascript" src="/js/plugins/image/previewImg.js"></script>
	<script>
		layui.config({
			//静态资源所在路径
			base : '/layuiadmin/'
		}).extend({
			//主入口模块
			index : 'lib/index'
		}).use([ 'index', 'form' ], function() {
			var $ = layui.$, layer = layui.layer, element = layui.element;
			
			var active = {
		    	cashThis : function(){
		    		layer.confirm('确认申请提现吗？', function(index){
						$.ajax({
				            url: "/account/handleBusinessCash",
				            data: $("#cashForm").serialize(),
				            dataType: "json",
				            type: "post",
				            success: function (data) {
				            	if (data.status) {
				                    layer.close(index);
				                    layer.msg(data.desc, {icon: 1})
				                    setTimeout(function () {
				                        window.location.reload();
				                    }, 1000)
				                } else {
				                    layer.close(index);
				                    layer.msg(data.desc, {icon: 2})
				                }
				            }
				        })
	                });
		    	}
		    };
			
			$(".cashThis").on("click", function(){
				var cashThis = $(this).data("type");
				active[cashThis] && active[cashThis].call(this);
			});
		});
		
		function planRealMoney () {
			var cashMoney = $("input[name='cashMoney']").val();
			var scale = $("#scale").val();
			var realMoney = parseFloat(cashMoney * scale).toFixed(2);
			$("input[name='realMoney']").val(parseFloat(cashMoney-realMoney).toFixed(2));
		}
	</script>
</body>
</html>